package com.sia.springcloud.protocol.model;

import com.sia.springcloud.model.Point;
import lombok.Data;

import java.io.Serializable;

/**
 * @Author: Sirius
 * @Date: 2021/10/3 20:16
 * @Description: 111
 **/
@Data
public class BoschPoint implements Serializable {
    private Integer id;
    private Integer collect;
    private Integer deviceId;
    private String protocolName;
    private String pointName;
    private Integer frequency;
    private String metricName;
    private String target;
    private String domain;
//    点位标识
    private String varKey;

    private static final long serialVersionUID = 1L;

    /**
     * 将Modbus变量对象转换成协议变量对象
     *
     * @param boschPoint
     * @return
     */
    public static Point convert(BoschPoint boschPoint) {
        Point point = new Point();
        point.setId(boschPoint.getId());
        point.setCollect(boschPoint.getCollect());
        point.setDeviceId(boschPoint.getDeviceId());
        point.setProtocolName(boschPoint.getProtocolName());
        point.setPointName(boschPoint.getPointName());
        point.setFrequency(boschPoint.getFrequency());
        point.setMetricName(boschPoint.getMetricName());
        point.setTarget(boschPoint.getTarget());
        point.setDomain(boschPoint.getDomain());
//        用str1存 变量标识 varKey
        point.setVarStr1(boschPoint.getVarKey());

        return point;
    }

    /**
     * 将Protocol变量对象转换成Modbus变量对象
     *
     * @param point
     * @return
     */
    public static BoschPoint reconvert(Point point) {
        BoschPoint boschPoint = new BoschPoint();
        boschPoint.setId(point.getId());
        boschPoint.setCollect(point.getCollect());
        boschPoint.setDeviceId(point.getDeviceId());
        boschPoint.setProtocolName(point.getProtocolName());
        boschPoint.setPointName(point.getPointName());
        boschPoint.setFrequency(point.getFrequency());
        boschPoint.setMetricName(point.getMetricName());
        boschPoint.setTarget(point.getTarget());
        boschPoint.setDomain(point.getDomain());
//        用str1存 变量标识 varKey
        boschPoint.setVarKey(point.getVarStr1());

        return boschPoint;
    }

}
